<extend name="Layout/ins_popup" />
<block name="content">	
	{:W('PageHeader/popup',array('name'=>'状态更改记录'))}
	<div class="row show " id="showState">
		<div class="col-sm-12">
            <table data-toggle="table"  >
                <thead>
                <tr>
                    <th data-field="state">状态</th>
                    <th data-field="startdate">开始时间</th>
                    <th data-field="enddate">结束时间</th>
                    <th data-field="remark">备注</th>
                </tr>
                </thead>
                <tbody>
                <volist name="stateList" id="state">
                    <tr >
                        <volist name="state" id="stateItem" >



                                <td>
                                    {$stateItem}
                                </td>
                        </volist>
                    </tr>
                </volist>
                </tbody>
            </table>
		</div>
	</div>

    <div class="row hidden" id="addState">
          <div class="col-sm-12">
              <form id="form_data" name="form_data" method="post" class="well form-horizontal clearfix"  >

                  <div class="form-group">
                      <label class="col-sm-3 control-label" for="state">状态：</label>
                      <div class="col-sm-9">
                          <select class="form-control"  name="state" id="state" >
                              <if condition="$state eq '0'">
                                  <option  value="0" selected="selected" >正常</option>
                                  <option value="1" >维修</option>
                                  <option value="2" >使用</option>
                                  <elseif condition="$state eq '1'"/>
                                  <option  value="0" >正常</option>
                                  <option value="1"  selected="selected" >维修</option>
                                  <option value="2" >使用</option>
                                  <else/>
                                  <option  value="0" >正常</option>
                                  <option value="1"   >维修</option>
                                  <option value="2"  selected="selected">使用</option>
                              </if>

                          </select>
                      </div>
                  </div>

                  <div class="form-group">
                      <input class="hidden" name="carid" value="{$carId}">
                      <label class="col-sm-3 control-label" for="make">备注*：</label>
                      <div class="col-sm-9">
                          <textarea class="form-control" type="text" id="remark" name="remark" check="require" msg="请输入备注">                                       </textarea>
                      </div>
                  </div>
                  <div class="form-group">
                      <button class="btn btn-danger pull-right" id="add">添加</button>
                  </div>

              </form>
          </div>



    </div>
</block>
<block name="js">
	<script type="text/javascript">
        $(".page-header .btn-primary").text('添加');

        $(".page-header .btn-primary").click(function(){

                $("#showState").removeClass('show').addClass('hidden');
                $("#addState").removeClass('hidden').addClass('show');
                $(this).hide();
        });


        $('#add').click(function(){
            if (check_form("form_data")) {
                var vars = $("#form_data").serialize();
                sendAjax("{:U('addCarState')}", vars, function(data) {
                    if (data.status) {
                        ui_alert(data.info, function() {
                             parent.location.reload(true);
                           // location.href="{:U('showCarInfoList')}";
                        });
                    }else{
                        ui_error(data.info);
                    }
                });
            }else{
                ui_error("未修改任何数据项");
            }
        });

	</script>
</block>